package com.wlgc.controller;

import com.wlgc.context.BaseContext;
import com.wlgc.entity.RestBean;
import com.wlgc.entity.vo.ChatListVO;
import com.wlgc.service.ChatService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/chat")
@PreAuthorize("hasAuthority('index')")
public class ChatController {

    @Autowired
    private ChatService chatService;

    //查询聊天列表
    @GetMapping("/list")
    public RestBean<List> getChatList(){

        List<ChatListVO> chatList = chatService.getFromUserChatList(BaseContext.getCurrentId());
        return RestBean.success(chatList);
    }
}
